package day11.task;

import java.util.*;

public class Srudent2 {
    private Integer no;
    private String name;
    private Double score;

    public Srudent2(Integer no, String name, Double score) {
        this.no = no;
        this.name = name;
        this.score = score;
    }

    public Integer getNo() {
        return no;
    }

    public void setNo(Integer no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Srudent2 srudent2 = (Srudent2) o;
        return Objects.equals(no, srudent2.no) ;
    }

    @Override
    public int hashCode() {
        return Objects.hash(no);
    }

    @Override
    public String toString() {
        return "Srudent2{" +
                "no: " + no + " name: " + name + " score: " + score;
    }
}
class Main{
    public static void main(String[] args) {
        Map<Integer,Srudent2> map=new HashMap<>();
        System.out.println("输入学生个数：");
        Scanner sc=new Scanner(System.in);
        int number = sc.nextInt();
        for (int i = 0; i < number; i++) {
            Srudent2 srudent2 = new Srudent2(sc.nextInt(), sc.next(), sc.nextDouble());
            map.put(srudent2.getNo(),srudent2);
        }
        int operation_count=sc.nextInt();
        for (int i = 0; i < operation_count; i++) {
            String s = sc.nextLine();
            String[] split = s.split(" ");
            if("add".equals(split[0])){
                map.put(Integer.parseInt(split[1]),new Srudent2(Integer.parseInt(split[1]),split[2],Double.parseDouble(split[3])));
            }else  if("delete".equals(split[0])){
                map.remove(split[1]);
            }else if("set".equals(split[0])){
                //直接改掉了
                map.get(Integer.parseInt(split[1])).setScore(Double.parseDouble(split[2]));
            }
        }
        //排序 由小到大
        Set<Integer> integers = map.keySet();
        List<Integer> int1=new ArrayList<>();
        Object[] objects = integers.toArray();
        Arrays.sort(objects, new Comparator<Object>() {
            @Override
            public int compare(Object o1,Object o2) {
//                return ((Integer) o1)-((Integer)o2); // 升序
              return ((Integer) o1).compareTo((Integer)o2);
                 }
        });
        for (Object o : objects) {
            System.out.println(o + "=" +map.get((Integer) o));
        }

    }
}
